<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <input type="hidden" name="idxProAdmin" id="idxProAdmin" value="${id}"/>
        <input type="hidden" name="idProReExamination" id="idProReExamination" value="${subsetId}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">
                开始时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="beginTime" name="beginTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                结束时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="endTime" name="endTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item" id="difference">
            <label class="layui-form-label">
                距离结束时间天数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="differenceTime" name="differenceTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>


        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>客户名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="customerName" name="customerName" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" disabled >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="constructionUnit" class="layui-form-label">
                <span class="x-red">*</span>施工单位
            </label>
            <div class="layui-input-inline">
                <input type="text" id="constructionUnit" name="constructionUnit" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="reExaminationType" class="layui-form-label">
                <span class="x-red">*</span>类别
            </label>
            <div class="layui-input-inline">
                <input type="text" id="reExaminationType" name="reExaminationType" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="checkAcceptanceProName" class="layui-form-label">
                <span class="x-red">*</span>验收项目
            </label>
            <div class="layui-input-inline">
                <input type="text" id="checkAcceptanceProName" name="checkAcceptanceProName" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="content" class="layui-form-label">
                <span class="x-red">*</span>存在问题
            </label>
            <div class="layui-input-inline">
                    <textarea id="content"  name="existingProblems" style="display: none;"
                              class="layui-hide"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="content1" class="layui-form-label">
                <span class="x-red">*</span>与图纸不符(施工，设备)
            </label>
            <div class="layui-input-inline">
                    <textarea id="content1"  name="designChartDiscrepancy" style="display: none;"
                              class="layui-hide"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="customerName" class="layui-form-label">
                <span class="x-red">*</span>整改意见（遗留问题）
            </label>
            <div class="layui-input-inline">
                    <textarea id="content2"  name="amendments" style="display: none;"
                              class="layui-hide"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="organizationalUnit" class="layui-form-label">
                <span class="x-red">*</span>组织单位
            </label>
            <div class="layui-input-inline">
                <input type="text" id="organizationalUnit" name="organizationalUnit" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item">
            <label for="acceptanceUnit" class="layui-form-label">
                <span class="x-red">*</span>验收单位
            </label>
            <div class="layui-input-inline">
                <input type="text" id="acceptanceUnit" name="acceptanceUnit" lay-verify="required" placeholder="请输入"
                       autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label for="organizationalUnitCharge" class="layui-form-label">
                <span class="x-red">*</span>组织单位负责人
            </label>
            <div class="layui-input-inline">
                <img class="layui-upload-img" src="" id="imgUrl11" width="100px" /><br><br><br>
                <input type="hidden" id="organizationalUnitCharge" name="organizationalUnitCharge"  >
                <button type="button" class="layui-btn" id="upload11">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button><script>
                updateFile("upload11","imgUrl11","organizationalUnitCharge");
            </script>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="constructionPersonCharge" class="layui-form-label">
                <span class="x-red">*</span>施工负责人
            </label>
            <div class="layui-input-inline">
                <img class="layui-upload-img" src="" id="imgUrl12" width="100px" /><br><br><br>
                <input type="hidden" id="constructionPersonCharge" name="constructionPersonCharge"  >
                <button type="button" class="layui-btn" id="upload12">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button><script>
                updateFile("upload12","imgUrl12","constructionPersonCharge");
            </script>
            </div>
        </div>



        <div class="layui-form-item">
            <label for="acceptanceUnitCharge" class="layui-form-label">
                <span class="x-red">*</span>验收单位负责人
            </label>
            <div class="layui-input-inline">
                <img class="layui-upload-img" src="" id="imgUrl13" width="100px" /><br><br><br>
                <input type="hidden" id="acceptanceUnitCharge" name="acceptanceUnitCharge"  >
                <button type="button" class="layui-btn" id="upload13">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button><script>
                updateFile("upload13","imgUrl13","acceptanceUnitCharge");
            </script>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="customerPersonCharge" class="layui-form-label">
                <span class="x-red">*</span>客户负责人
            </label>
            <div class="layui-input-inline">
                <img class="layui-upload-img" src="" id="imgUrl14" width="100px" /><br><br><br>
                <input type="hidden" id="customerPersonCharge" name="customerPersonCharge"  >
                <button type="button" class="layui-btn" id="upload14">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button><script>
                updateFile("upload14","imgUrl14","customerPersonCharge");
            </script>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="livePhotos1" class="layui-form-label">
                <span class="x-red">*</span>现场照片上传：<br/>
                <div style="color: #797474;margin-top: 9px;">注：上传图片</div>
            </label>
            <div class="layui-input-inline" >
                <br>
                <a><img class="layui-upload-img" src="" id="imgUrl1" width="100px" /></a>
                <br><br><br>
                <input type="hidden" name="livePhotos" id="livePhotos1" >
                <button type="button" class="layui-btn" id="upload1">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <script>
                    updateFile("upload1","imgUrl1","livePhotos1");
                </script>

                <br>
                <a>
                    <img class="layui-upload-img" src="" id="imgUrl2" width="100px" />
                </a>
                <br><br><br>
                <input type="hidden" name="livePhotos" id="livePhotos2"   >
                <button type="button" class="layui-btn" id="upload2">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <script>
                    updateFile("upload2","imgUrl2","livePhotos2");
                </script>

                <br>
                <a><img class="layui-upload-img" src="" id="imgUrl3" width="100px" /></a><br><br><br>
                <input type="hidden" name="livePhotos" id="livePhotos3"   >
                <button type="button" class="layui-btn" id="upload3">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <script>
                    updateFile("upload3","imgUrl3","livePhotos3");
                </script>

                <br>
                <a><img class="layui-upload-img" src="" id="imgUrl4" width="100px" /></a>
                <br><br><br>
                <input type="hidden" name="livePhotos" id="livePhotos4"   >
                <button type="button" class="layui-btn" id="upload4">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <script>
                    updateFile("upload4","imgUrl4","livePhotos4");
                </script>
            </div>
        </div>


        <div class="layui-form-item">
            <label for="livePhotos1" class="layui-form-label">
                <span class="x-red">*</span>整改报告：<br/>
                <div style="color: #797474;margin-top: 9px;">注：word，pdf，jpg</div>
            </label>
            <div class="layui-input-inline" >
                <br>
                <a><img class="layui-upload-img" src="" id="imgUrl5" width="100px" /></a>
                <br><br><br>
                <input type="hidden" name="rectificationReport" id="rectificationReport1" >
                <button type="button" class="layui-btn" id="upload5">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <script>
                    updateFile("upload5","imgUrl5","rectificationReport1");
                </script>

                <br>
                <a><img class="layui-upload-img" src="" id="imgUrl6" width="100px" /></a>
                <br><br><br>
                <input type="hidden" name="rectificationReport" id="rectificationReport2"   >
                <button type="button" class="layui-btn" id="upload6">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <script>
                    updateFile("upload6","imgUrl6","rectificationReport2");
                </script>

                <br>
                <a><img class="layui-upload-img" src="" id="imgUrl7"  width="100px"/></a>
                <br><br><br>
                <input type="hidden" name="rectificationReport" id="rectificationReport3"   >
                <button type="button" class="layui-btn" id="upload7">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <script>
                    updateFile("upload7","imgUrl7","rectificationReport3");
                </script>
                <br>

                <a><img class="layui-upload-img" src="" id="imgUrl8" width="100px" /></a>
                <br><br><br>
                <input type="hidden" name="rectificationReport" id="rectificationReport4"   >
                <button type="button" class="layui-btn" id="upload8">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <script>
                    updateFile("upload8","imgUrl8","rectificationReport4");
                </script>
            </div>
        </div>

        <div class="layui-form-item" id="submitButton">
            <label for="" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="preservation" type=button codeTyle="1" lay-submit="">
                保存
            </button>
            <button  class="layui-btn" lay-filter="preAdd" type=button codeTyle="2" lay-submit="">
                预提交
            </button>
            <button  class="layui-btn" lay-filter="add" type=button codeTyle="3" lay-submit="">
                提交
            </button>
        </div>
        <div class="layui-form-item" id="updateStart">
            <label for="" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="update" type=button codeTyle="0" lay-submit="">
                修改
            </button>
        </div>
    </form>
</div>
<script>
    var layedit = '';
    layui.use('layedit', function(){
        layedit = layui.layedit;
        layedit.set({
            uploadImage: {
                url: path + '/pc/upload/uploadFile' //接口url
                ,type: 'post' //默认post
            }
        });
        contentIndex = layedit.build("content"); //建立编辑器
        contentIndex1 = layedit.build("content1"); //建立编辑器
        contentIndex2 = layedit.build("content2"); //建立编辑器
    });
    $(function(){
        ajaxFun('get','/pc/project/getProjectBaseInfo',{"idProAdmin":$("#idxProAdmin").val()},function(data){
            if(data.code != 0){
                alertFun(data);
            }else{
                $("#customerName").val(data.data.customerName);
            }
        })

        var index = 42;
        getProTime($("#idxProAdmin").val(),40);
        layui.use('layedit', function() {
            layedit = layui.layedit;
            ajaxFun('get','/pc/project/getIntermediateInspectionInfo',{"idProReExamination": $("#idProReExamination").val(),"status":index},function(data){
                if (data.code != 0) {
                    alertFun(data);
                } else {
                    if (data.data.submitState === 3) {
                        $("#submitButton").hide();
                        $("#updateStart").show();
                        $("#difference").hide();
                    } else {
                        $("#submitButton").show();
                        $("#updateStart").hide();
                    }
                    $("#idProReExamination").val(data.data.idProReExamination);

                    $("#constructionUnit").val(data.data.constructionUnit);
                    $("#reExaminationType").val(data.data.reExaminationType);
                    $("#checkAcceptanceProName").val(data.data.checkAcceptanceProName);
                    $("input[name='checkAcceptanceProName']").val(data.data.checkAcceptanceProName);

                    $("input[name='progressProjectDescribe']").val(data.data.progressProjectDescribe);
                    $("input[name='amendments']").val(data.data.amendments);
                    $("input[name='designChartDiscrepancy']").val(data.data.designChartDiscrepancy);
                    $("#organizationalUnit").val(data.data.organizationalUnit);
                    $("#acceptanceUnit").val(data.data.acceptanceUnit);

                    $("#organizationalUnitCharge").val(data.data.organizationalUnitCharge);
                    $("#imgUrl11").attr("src",getIos(data.data.organizationalUnitChargeFileSuffixName,
                        data.data.organizationalUnitChargeFilePath));
                    $("#imgUrl11").parent().attr("href",data.data.organizationalUnitChargeFilePath);

                    $("#customerPersonCharge").val(data.data.customerPersonCharge);
                    $("#imgUrl12").attr("src",getIos(data.data.customerPersonChargeFileSuffixName,data.data.customerPersonChargeFilePath));
                    $("#imgUrl12").parent().attr("href",data.data.customerPersonChargeFilePath);

                    $("#acceptanceUnitCharge").val(data.data.acceptanceUnitCharge);
                    $("#imgUrl13").attr("src",getIos(data.data.acceptanceUnitChargeFileSuffixName,
                        data.data.acceptanceUnitChargeFilePath));
                    $("#imgUrl13").parent().attr("href",data.data.acceptanceUnitChargeFilePath);

                    $("#constructionPersonCharge").val(data.data.constructionPersonCharge);
                    $("#imgUrl14").attr("src",getIos(data.data.constructionPersonChargeFileSuffixName,
                        data.data.constructionPersonChargeFilePath));
                    $("#imgUrl14").parent().attr("href",data.data.constructionPersonChargeFilePath);

                    layedit.setContent(contentIndex, data.data.existingProblems);
                    layedit.setContent(contentIndex1, data.data.designChartDiscrepancy);
                    layedit.setContent(contentIndex2, data.data.amendments);

                    for (var i = 0; i < data.data.scenePicturesList.length; i++) {
                        $("#imgUrl" + (i + 1)).attr("src", getIos(data.data.scenePicturesList[i].suffixName,
                            data.data.scenePicturesList[i].filePath));
                        $("#imgUrl" + (i + 1)).parent().attr("href", data.data.scenePicturesList[i].filePath);
                        $("#livePhotos" + (i + 1)).val(data.data.scenePicturesList[i].fileId);
                    }

                    for (var i = 0; i < data.data.rectificationUnitSubmitsRectificationReportList.length; i++) {
                        $("#imgUrl" + (i + 5)).attr("src", getIos(data.data.rectificationUnitSubmitsRectificationReportList[i].suffixName,
                            data.data.rectificationUnitSubmitsRectificationReportList[i].filePath));
                        $("#imgUrl" + (i + 5)).parent().attr("href", data.data.rectificationUnitSubmitsRectificationReportList[i].filePath);
                        $("#rectificationReport" + (i + 1)).val(data.data.rectificationUnitSubmitsRectificationReportList[i].fileId);
                    }
                }
            })
        })
    })
    layui.use(['form','layer'], function() {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer, layedit = layui.layedit;

        //自定义验证规则
        form.verify({});

        //监听提交
        form.on('submit(add)', function (t) {
            addSubmit(3);
        });

        //监听保存
        form.on('submit(preservation)', function (t) {
            addSubmit(1);
        });

        //监听预提交
        form.on('submit(preAdd)', function (t) {
            addSubmit(2);
        });

        //修改
        form.on('submit(update)', function (t) {
            addSubmit(10);
        });
    });

    function addSubmit(submitState){

        var livePhotos=new Array(),i = 0;
        $("input[name='livePhotos']").each(function(){
            if(isNotNull($(this).val())) {
                var data = {
                    idSysFiles: $(this).val(),
                    resourcesType: 1
                };
                livePhotos[i] = data;
                i++;
            }
        })

        var rectificationReport=new Array(),i = 0;
        $("input[name='rectificationReport']").each(function(){
            if(isNotNull($(this).val())){
                var data = {
                    idSysFiles: $(this).val(),
                    resourcesType : 2
                };
                rectificationReport[i] = data;
                i++;
            }
        })

        var params = {
            //tcaDescribe : layui.layedit.getContent(index),
            "idProAdmin": $("#idxProAdmin").val(),
            "testType": 1,
            "idProReExamination": $("#idProReExamination").val(),
            "constructionUnit": $("#constructionUnit").val(),
            "reExaminationType": $("#reExaminationType").val(),
            "checkAcceptanceProName": $("#checkAcceptanceProName").val(),

            "organizationalUnit": $("#organizationalUnit").val(),
            "organizationalUnitCharge": $("#organizationalUnitCharge").val(),
            "constructionPersonCharge": $("#constructionPersonCharge").val(),
            "acceptanceUnit": $("#acceptanceUnit").val(),
            "acceptanceUnitCharge": $("#acceptanceUnitCharge").val(),
            "customerPersonCharge": $("#customerPersonCharge").val(),
            "livePhotosList":livePhotos,
            "rectificationReportList":rectificationReport,
            "existingProblems" : layedit.getContent(contentIndex),
            "designChartDiscrepancy" : layedit.getContent(contentIndex1),
            "amendments" : layedit.getContent(contentIndex2),

            "submitState":submitState
        }
        if (true) {
            ajaxFunJson('post','/pc/project/updateIntermediateInspection',JSON.stringify(params),function(data){
                if (data.code != 0) {
                    alertFun(data);
                } else {
                    window.location.href = path + "/modules/project/threePro/fj/list.html";
                    console.log("success !");
                }
            })
            return false;
        }
    }
</script></body></html>